/*
<CALENDAR-Tool To Perform Calendar Related Functions.>
    Copyright (C) <2011>  <SHIVAM MATHUR--shivam_jpr@hotmail.com>

    This program is free software: you can redistribute it and/or modify
    the software until it is not mentioned in the source,
    under the terms of the GNU Affero General Public License as
    published by the Free Software Foundation, either version 3 of the
    License, or any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

	Note that the username is- 	shivam
	and the password is- 		cool
*The password can be changed but it must be notified with the distribution and scapping the password feature would mean copyright infringement
*The terms and conditions given below or in the licence.txt(https://sourceforge.net/projects/c-cpp-calender/files/licence.txt) follow to every part of the program until and unless explictly mentioned
 these terms and conditons might change without your prior information and in any case the licence terms as
 mentioned in the latest version of -(https://sourceforge.net/projects/c-cpp-calender/files/licence.txt)
 would be valid and applicable.
*The redistributors are expected to use the screenshots provided with the project than rather than creating their own.
*The icon of Calendar must not be changed and in any case the icon provided with the project must be used.
*/
#include <iostream>   				//For all the stream input-output operations
#include <string>					//For all the string related functions
#include <stdio.h>					//For all the standard input/output functions
#include <math.h>					//For all the standard mathematical functions
#include <windows.h>				//For all the functions required to access WINDOWS API
#include <ctype.h>					//For all the character related functions
#include <stdlib.h>					//For all the Standard Library Functions (such as atoi)
/**********************************************************GLOBAL IDENTIFIERS********************************************************************/
int  a, i=0, j, m, q, s, u, w, x, y, z, ri, bt, kl, yeno = 0, cenno = 0, date = 0, dinno=0, mon =0, year = 0,  daynum = 0, again = 0, met, 
	 counter = 1, wrap = 0, startDOW = 0, weekNumber = 0, dayCounter = 1, loopCount = 0, ket, ret, flag, acc, lim, strno, fla = 0, ch = 0,
	 month		[12] = {6, 1, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 },  
	 daysInMonth[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
	
char uchk[10],pchk[10],bul=16,ch1,day[10],usrn[10],pass[10],pchoice,bi,numstr[15],str[15],strcase,
	 week	[ 7][10] = {"Sunday", "Monday","Tuesday", "Wednesday","Thursday","Friday","Saturday"},
	 months [12][10] = {"January","February","March","April","May","June","July","August","September","October","November","December"};
/************************************************************************************************************************************************/
#ifdef __BORLANDC__
#else
using std::cout;
using std::cin;
using std::endl;
#endif
/************************************************************************************************************************************************/
//  comments as provided in md5.h are mentioned below
//	used with permission as mentioned below
// Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
// rights reserved.

// License to copy and use this software is granted provided that it
// is identified as the "RSA Data Security, Inc. MD5 Message-Digest
// Algorithm" in all material mentioning or referencing this software
// or this function.
//
// License is also granted to make and use derivative works provided
// that such works are identified as "derived from the RSA Data
// Security, Inc. MD5 Message-Digest Algorithm" in all material
// mentioning or referencing the derived work.
//
// RSA Data Security, Inc. makes no representations concerning either
// the merchantability of this software or the suitability of this
// software for any particular purpose. It is provided "as is"
// without express or implied warranty of any kind.
//
// These notices must be retained in any copies of any part of this
// documentation and/or software.

// The original md5 implementation avoids external libraries.
// This version has dependency on stdio.h for file input and
// string.h for memcpy.
#ifndef MD5_H
#define MD5_H
// Constants for MD5Transform routine.
#define S11 7
#define S12 12
#define S13 17
#define S14 22
#define S21 5
#define S22 9
#define S23 14
#define S24 20
#define S31 4
#define S32 11
#define S33 16
#define S34 23
#define S41 6
#define S42 10
#define S43 15
#define S44 21

static unsigned char PADDING[64] = {
  0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};

// F, G, H and I are basic MD5 functions.
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define I(x, y, z) ((y) ^ ((x) | (~z)))

// ROTATE_LEFT rotates x left n bits.
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))

// FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
// Rotation is separate from addition to prevent recomputation.
#define FF(a, b, c, d, x, s, ac) { \
  (a)+=F ((b), (c), (d)) + (x) + (UINT4)(ac); \
  (a)=ROTATE_LEFT ((a), (s)); \
  (a)+=(b); \
  }
#define GG(a, b, c, d, x, s, ac) { \
  (a)+= G ((b), (c), (d)) + (x) + (UINT4)(ac); \
  (a)=ROTATE_LEFT ((a), (s)); \
  (a)+=(b); \
  }
#define HH(a, b, c, d, x, s, ac) { \
  (a)+=H ((b), (c), (d)) + (x) + (UINT4)(ac); \
  (a)=ROTATE_LEFT ((a), (s)); \
  (a)+=(b); \
  }
#define II(a, b, c, d, x, s, ac) { \
  (a)+=I ((b), (c), (d)) + (x) + (UINT4)(ac); \
  (a)=ROTATE_LEFT ((a), (s)); \
  (a)+=(b); \
  }


typedef unsigned char BYTE ;

// POINTER defines a generic pointer type
typedef unsigned char *POINTER;

// UINT2 defines a two byte word
typedef unsigned short int UINT2;

// UINT4 defines a four byte word
typedef unsigned long int UINT4;

// convenient object that wraps
// the C-functions for use in C++ only
class MD5
{
private:
  struct __context_t {
    UINT4 state[4];                                   /* state (ABCD) */
    UINT4 count[2];        /* number of bits, modulo 2^64 (lsb first) */
    unsigned char buffer[64];                         /* input buffer */
  } context ;

  
  // The core of the MD5 algorithm is here.
  // MD5 basic transformation. Transforms state based on block.
  static void MD5Transform( UINT4 state[4], unsigned char block[64] )
  {
    UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];

    Decode (x, block, 64);

    /* Round 1 */
    FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
    FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
    FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
    FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
    FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
    FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
    FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
    FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
    FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
    FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
    FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
    FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
    FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
    FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
    FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
    FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */

    /* Round 2 */
    GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
    GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
    GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
    GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
    GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
    GG (d, a, b, c, x[10], S22,  0x2441453); /* 22 */
    GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
    GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
    GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
    GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
    GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
    GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
    GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
    GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
    GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
    GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */

    /* Round 3 */
    HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
    HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
    HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
    HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
    HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
    HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
    HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
    HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
    HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
    HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
    HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
    HH (b, c, d, a, x[ 6], S34,  0x4881d05); /* 44 */
    HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
    HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
    HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
    HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */

    /* Round 4 */
    II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
    II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
    II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
    II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
    II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
    II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
    II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
    II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
    II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
    II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
    II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
    II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
    II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
    II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
    II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
    II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */

    state[0] += a;
    state[1] += b;
    state[2] += c;
    state[3] += d;

    // Zeroize sensitive information.
    memset((POINTER)x, 0, sizeof (x));
  }

  // Encodes input (UINT4) into output (unsigned char). Assumes len is
  // a multiple of 4.
  static void Encode( unsigned char *output, UINT4 *input, unsigned int len )
  {
    unsigned int i, j;

    for (i = 0, j = 0; j < len; i++, j =j+4) {
      output[j] = (unsigned char)(input[i] & 0xff);
      output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
      output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
      output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
    }
  }

  // Decodes input (unsigned char) into output (UINT4). Assumes len is
  // a multiple of 4.
  static void Decode( UINT4 *output, unsigned char *input, unsigned int len )
  {
    unsigned int i, j;

    for (i = 0, j = 0; j < len; i++, j =j+4)
      output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
      (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
  }
  


public:
  // MAIN FUNCTIONS
  MD5()
  {
    Init() ;
  }

  // MD5 initialization. Begins an MD5 operation, writing a new context.
  void Init()
  {
    context.count[0] = context.count[1] = 0;

    // Load magic initialization constants.
    context.state[0] = 0x67452301;
    context.state[1] = 0xefcdab89;
    context.state[2] = 0x98badcfe;
    context.state[3] = 0x10325476;
  }

  // MD5 block update operation. Continues an MD5 message-digest
  // operation, processing another message block, and updating the
  // context.
  void Update(
    unsigned char *input,   // input block
    unsigned int inputLen ) // length of input block
  {
    unsigned int i, index, partLen;

    // Compute number of bytes mod 64
    index = (unsigned int)((context.count[0] >> 3) & 0x3F);

    // Update number of bits
    if ((context.count[0] += ((UINT4)inputLen << 3))
      < ((UINT4)inputLen << 3))
      context.count[1]++;
    context.count[1] += ((UINT4)inputLen >> 29);

    partLen = 64 - index;

    // Transform as many times as possible.
    if (inputLen >= partLen) {
      memcpy((POINTER)&context.buffer[index], (POINTER)input, partLen);
      MD5Transform (context.state, context.buffer);

      for (i = partLen; i + 63 < inputLen; i =i+64)
        MD5Transform (context.state, &input[i]);

      index = 0;
    }
    else
      i = 0;

    /* Buffer remaining input */
    memcpy((POINTER)&context.buffer[index], (POINTER)&input[i], inputLen-i);
  }

  // MD5 finalization. Ends an MD5 message-digest operation, writing the
  // the message digest and zeroizing the context.
  // Writes to digestRaw
  void Final()
  {
    unsigned char bits[8];
    unsigned int index, padLen;

    // Save number of bits
    Encode( bits, context.count, 8 );

    // Pad out to 56 mod 64.
    index = (unsigned int)((context.count[0] >> 3) & 0x3f);
    padLen = (index < 56) ? (56 - index) : (120 - index);
    Update( PADDING, padLen );

    // Append length (before padding)
    Update( bits, 8 );

    // Store state in digest
    Encode( digestRaw, context.state, 16);

    // Zeroize sensitive information.
    memset((POINTER)&context, 0, sizeof (context));

    writeToString() ;
  }

  /// Buffer must be 32+1 (nul) = 33 chars long at least
  void writeToString()
  {
    int pos ;

    for( pos = 0 ; pos < 16 ; pos=pos+1 )
      sprintf( digestChars+(pos*2), "%02x", digestRaw[pos] ) ;
  }

public:
  // an MD5 digest is a 16-byte number (32 hex digits)
  BYTE digestRaw[ 16 ] ;

  // This version of the digest is actually
  // a "printf'd" version of the digest.
  char digestChars[ 33 ] ;

  /// Load a file from disk and digest it
  // Digests a file and returns the result.
  char* digestFile( char *filename )
  {
    Init() ;

    FILE *file;

    int len;
    unsigned char buffer[1024] ;

    if( (file = fopen (filename, "rb")) == NULL )
      printf( "%s can't be opened\n", filename ) ;
    else
    {
      while( len = fread( buffer, 1, 1024, file ) )
      Update( buffer, len ) ;
      Final();

      fclose( file );
    }

    return digestChars ;
  }

  /// Digests a byte-array already in memory
  char* digestMemory( BYTE *memchunk, int len )
  {
    Init() ;
    Update( memchunk, len ) ;
    Final() ;

    return digestChars ;
  }

  // Digests a string and prints the result.
  char* digestString( char *string )
  {
    Init() ;
    Update( (unsigned char*)string, strlen(string) ) ;
    Final() ;

    return digestChars ;
  }
} ;


#endif
/***************************************************************************************************************************************/

/*********************************************************Calendar Class***************************************************************/
class calendar	
{
	/** 
	This is the Main class of the Calendar Program
	it contains all the member functions required to
	perform all the calender related tasks in this calender
	appication.
	*/ 
/***************************************************************************************************************************************/	
private:

int digesMD5();
void setpos();
void newline();

/***************************************************************************************************************************************/
void cls( HANDLE hConsole )
{
   COORD coordScreen = { 0, 0 };
   DWORD cCharsWritten;
   CONSOLE_SCREEN_BUFFER_INFO csbi; 
   DWORD dwConSize;
   if( !GetConsoleScreenBufferInfo( hConsole, &csbi ))
         return;
   dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
   if( !FillConsoleOutputCharacter( hConsole,(TCHAR)' ',dwConSize,coordScreen,&cCharsWritten ))
         return;
   if( !GetConsoleScreenBufferInfo( hConsole, &csbi ))
         return;
   if( !FillConsoleOutputAttribute(hConsole,csbi.wAttributes,dwConSize,coordScreen,&cCharsWritten )) 
         return;
   SetConsoleCursorPosition( hConsole, coordScreen );
}

/***************************************************************************************************************************************/
public:	

int chkstr();
int chkdate();				
void day2date ();
void printAll();
void monthcal();
	
/***************************************************************************************************************************************/	
void roadblock()											/**
														Function to access the private member funtion digestMD5
														and return a value to verify if the credentials enterted match.
														*/
{
	a = digesMD5();
}
/***************************************************************************************************************************************/	
void setscr()											//Function to set the size of the console screen
{
	HANDLE hOut;
    CONSOLE_SCREEN_BUFFER_INFO SBInfo;
    SMALL_RECT DisplayArea = {0, 0, 0, 0}; //Structure in windows library--Defines the coordinates of the upper left and lower right corners of a rectangle.
    hOut = GetStdHandle(STD_OUTPUT_HANDLE);
    GetConsoleScreenBufferInfo(hOut,&SBInfo);
    SBInfo.srWindow.Right;
    SBInfo.srWindow.Bottom;
    DisplayArea.Right = ri;
	DisplayArea.Bottom = bt;
    SetConsoleWindowInfo(hOut,TRUE,&DisplayArea);
}

/***************************************************************************************************************************************/	
	
CONSOLE_SCREEN_BUFFER_INFO csbi;						//Function to go to any point of the console screen(Taken from CONIO library)
void gotoxy ( short x, short y )
{  COORD coord = {x, y};
   SetConsoleCursorPosition ( GetStdHandle ( STD_OUTPUT_HANDLE ), coord ); //SetConsoleCursorPosition--A COORD structure that contains the column and row coordinates of the cursor in the console screen buffer.
}

COORD getxy (  CONSOLE_SCREEN_BUFFER_INFO * csbi)		//Function to get the position of the cursor the screen
{
	
	COORD coord = csbi->dwCursorPosition;
	return coord;
}

/***************************************************************************************************************************************/

char GetCh()											//Function to accept a character from the keyboard(Taken from CONIO library)
{
	HANDLE hStdin = GetStdHandle (STD_INPUT_HANDLE);
	INPUT_RECORD irInputRecord;
	DWORD dwEventsRead;
	char cChar;

  while(ReadConsoleInputA (hStdin, &irInputRecord, 1, &dwEventsRead)) // Read key press 
    if	(
		irInputRecord.EventType == KEY_EVENT
		&&irInputRecord.Event.KeyEvent.wVirtualKeyCode != VK_SHIFT
		&&irInputRecord.Event.KeyEvent.wVirtualKeyCode != VK_MENU
		&&irInputRecord.Event.KeyEvent.wVirtualKeyCode != VK_CONTROL
		)
			{
				cChar = irInputRecord.Event.KeyEvent.uChar.AsciiChar;
				ReadConsoleInputA (hStdin, &irInputRecord , 1, &dwEventsRead);   //Read key release 
				return cChar;
			}
	return EOF;
}

/***************************************************************************************************************************************/

void docls()
{
    HANDLE hStdout;
    hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
    cls(hStdout); 
}

/***************************************************************************************************************************************/

int dayno()										/**
													Function to give the dayno of any date 
													For eg if day is Sunday on a date, dayno is '0'
												*/
{
//int digit_year=ceil(log10(fabs(year)+1));
//int start_digits=year/pow(10,digit_year-2);

if (year%4 == 0 && (year %100 != 0 || year%400 == 0))//Updation of the array containing no of days in a month, if leap year is detected
{
   daysInMonth[1] = 29;								//updation of days in feb in Gregorian calendar
   month[0]		  = 5;								//updating the month no for january
   month[1]       = 1;								//updating the month no for febuary
}
else
{
   daysInMonth[1] = 28;								//updation of days in feb in Gregorian calendar
   month[0]		  = 6;								//updating the month no for january
   month[1]       = 2;								//updating the month no for febuary
}

int yearnum=year/100;

	x=year%100;	y=x/4;	z=x+y;	yeno=z%7;

if (yearnum%4==0)	cenno=0;
if (yearnum%4==1)	cenno=5;
if (yearnum%4==2)	cenno=3;
if (yearnum%4==3)	cenno=1;

	dinno =	(((cenno+yeno+month[mon-1])%7)+date)%7;
	return dinno;
}
/***************************************************************************************************************************************/
char repeat()																//Function to repeat the program
{
      if (ch>4)
         {
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),12);
			gotoxy( 40,9); cout<<"\t!!!WRONG CHOICE!!!\n";
         }
      if(ch>4)
		 {
		   gotoxy( 0,26);
		   SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15);
		   cout<<"   Do you want to Enter your Choice Again (y/n)\t";
		 }
	  else if(ch==3)
   	      gotoxy(0,47);
	  else
		  gotoxy( 0,22);
      SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15);
      if(ch<5)
	  cout<<"   Do you want to go to Options Menu Again (y/n)\t";				//Asking the user if he wants to repeat the program			
   
	  if(ch==3)																//This if-else construct just aligns the cursor 
		{gotoxy(48,47); 	cin>>ch1; }
      else if (ch==2)
		{gotoxy(48,22); 	cin>>ch1; }
      else if (ch> 4)
		{gotoxy(48,26); 	cin>>ch1; }
      else
		{gotoxy(48, 22);	cin>>ch1; }
      return ch1;
}
}cal; //object of Class calendar
/**
end of calendar class
*
/***************************************************************************************************************************************/
/******************************************************OUTLINE FUNCTIONS****************************************************************/
void calendar::setpos()								//Function to give a horizontal tab while printing tabular calendar
	{
		if(s<3)								//This if-else construct checks for the month and sets the alignment
		gotoxy(28*s+q,w+2);					
		else if (s>=3 && s<6)
		gotoxy(28*(s-3)+q,13+w);
		else if (s>=6 && s<9)
		gotoxy(28*(s-6)+q,24+w);
		else if (s>=9 && s<12)
		gotoxy(28*(s-9)+q,35+w);
	}

/***************************************************************************************************************************************/

void calendar::newline()								//Function for nextline ("\n") while printint tabular calendar		
	{	
		if(s<3)								//This if-else construct checks for the month and prints the newline  
		gotoxy(28*s+1,u);					//and redirects the cursor to set proper alignment
		else if (s>=3 && s<6)
		gotoxy(28*(s-3)+1,u);
		else if (s>=6 && s<9)
		gotoxy(28*(s-6)+1,u);
		else if (s>=9 && s<12)
		gotoxy(28*(s-9)+1,u);
	}
/***************************************************************************************************************************************/

int calendar::digesMD5()											//Function for password protection
{
	MD5 md5 ;
	COORD coord;
   //----------------------------Local Identifiers for digesMD5()----------------------//
		int  v=33;
		char str3[33] = "3ae9d8799d1bb5e201e5704293bb54ef";	//--hash of username(shivam)--
		char str4[33] = "b1f4f9a523e36fd969f4573e25af4540";	//--hash of password(cool)--
		char c[14], getusrn2str [33], getpass2str [33];
   //---------------------------------------------------------------------------------//
	docls();
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 2);	//Function to change the colour of output handle in the console		
	gotoxy(28,8);		cout<<"___________________";
	gotoxy(28,16);		cout<<"___________________";
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15);
	gotoxy(34,8);		cout<<"WELCOME";
	gotoxy(28,10);		cout<<"Enter the username\n";
	gotoxy(28,11);		cin>>usrn;	
	char* str1  = md5.digestString(usrn);
	strcpy(getusrn2str, str1);  									//converting char* to char[]
	gotoxy(28,13);		cout<<"Enter the password\n";
	i=0;
	gotoxy(28,14);
	while(i!=13)													//Loop until 'Enter' is pressed
		{
			enter:
			c [i]= GetCh();
			if(c[i]==13)
				{
    				break;
				}
			if(c[i]!=13 && c[i]!=0 && c[i]!=9 && c[i]!=27 && c[i]!=32 && c[i]!=18 && c[i]!=-32 )	//condition to prevent the special character to be inputted into password
				{
					if (c[i]==8)																	//Condition to erase password if backspace is pressed
						{
							GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
							coord = getxy( &csbi);
							kl= coord.X-1;
							gotoxy(kl,coord.Y);
							putchar('\0')   ;i--;													//putting a null character
							GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
							coord = getxy( &csbi);
		
							if(coord.X<29)
								gotoxy(29,14) ;
	
							GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
							coord = getxy( &csbi);
							kl= coord.X-1;
							gotoxy(kl,coord.Y);
							goto enter;																//After erasing sending the control to input handle again
						}
					else
						{
							putchar('*');															//Masking an '*' over the password characters
							bi=EOF; z=bi+5;	//must be changed to change the length of password	//setting z =4(I was too lazy to type 4)
							if (i<z)
								pchk[i]=c[i];
							GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
							coord = getxy( &csbi);
							i=coord.X-28;
						}
				}
		}
	cout<<"\n";
	char* str2  = md5.digestString(pchk);
	strcpy(getpass2str,str2);						 //converting char* to char[]
	while(v-->0)
		{
			if(getpass2str[v]==str4[v] && getusrn2str[v]==str3[v])
      			acc=0;
			else if(getpass2str[v]!=str4[v] || getusrn2str[v]!=str3[v])
      			{
      				acc=1;
      				break;
      				
      			}
      		if (acc==1)	break;
		}
      if(acc==1)
      	return 1;
      else
      	return 5;									//returning something !=1
}

/***************************************************************************************************************************************/
int calendar::chkdate()											/**
														Function to check if the date entered by the user is correct
														and also check if the date is of the past or a future date 
														or it is today's date
														(works on system date)(uses SYSTEMTIME class in WINDOWS.H)
														*/

{
	again=0;
    if (year%4 == 0 && (year %100 != 0 || year%400 == 0))				//Updation of the array containing no of days in a month, if leap year is detected
	daysInMonth[1]=29;
	
	if(date>daysInMonth[mon-1] || date <1 )								//checking if the date is not correct
	{
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),10);
		gotoxy(27, 4);	cout<<"Wrong date entered--WAIT";
		again=1 ;
		for(w=0;w<1000000000;w++){};
	}
	else if(fla==2 || mon > 12)														//checking if the month is not correct
	{
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),10);
		gotoxy(26, 4);	cout<<"Enter month correctly--WAIT";
		again=1 ;
		for(w=0;w<1000000000;w++){};
	}
	else if(year<1752 || year>9999)										//checking if the year is not between (1700-2300)
	{ 
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),10);	
		gotoxy(24, 4);	cout<<"Enter year from 1753-9999--WAIT";       /*In 1752 some days in sept were omitted as per the calendar change which creates 
																	     wrong display of calendar before sept 1752 from the algoritm used.*/  
		for(w=0;w<1000000000;w++){};
		again=1	;
	}
	else if(strno>7)										//checking if the year is not between (1700-2300)
	{ 
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),10);	
		gotoxy(24, 4);	cout<<"Enter DAY correctly--WAIT";
		for(w=0;w<1000000000;w++){};
		again=1	;
	}
	
	SYSTEMTIME ChkDate;
    GetSystemTime(&ChkDate);
	if(ChkDate.wYear > year)											//Checking if the date is of the past or a future date 
		flag = 0;														//or it is Today's date	
	else if(ChkDate.wYear < year)
		flag = 1;
	else if(ChkDate.wYear == year)
	{
		if(ChkDate.wMonth > mon)
			flag = 0;
		else if(ChkDate.wMonth < mon)
			flag = 1;
		else if(ChkDate.wMonth == mon)
		{
			if(ChkDate.wDay > date)
				flag = 0;
			else if(ChkDate.wDay < date)
				flag = 1;
			else if(ChkDate.wDay == date)	
				flag = 2;
		}
	}
	return again;
	return flag;
}
/***************************************************************************************************************************************/

int calendar::chkstr()						/**
									function to read day name or month name from the user 
									and assign a number to it for identification
									*/
{
	fla=0;
	if(isdigit(str[0])==0)							
	{
		for(i=0;i<=lim;i++)
		{
			if(isupper(str[i]))
			str[i] = tolower(str[i]);
		}
		if(isupper(str[0])==0)			
			str[0]-=32;								//making the string title case
	}
	strno = 8; 
	for(i=0;i<=lim;i++)								//loop to recognise a string and assign a number to it													
		{	
			fla = 0;
			if(strcase == 'm')
				ret=strncmp(str,months[i],3);																		
			else if(strcase == 'd')
				ret=strncmp(str,week[i],3);
			if(ret == 0)
				{
					if(strcase == 'm')
					{
						strno = i+1;				//storing the string code
						break;
					}
					else if(strcase == 'd')
					{
						strno = i; 
						break;
					}
				}
			else if (strcase == 'm') fla = 2;
		}
		cout<<strno;
	return strno;
	return fla;
}

/***************************************************************************************************************************************/

void calendar::printAll()								//Function to print the calendar of year
{
	ri=77;		bt=50;		setscr();
	COORD coord;
  	if(ch==3)
	{
		for(m=0;m<5;m++)					//Loop of print lines to give a Tubular look
			{
				gotoxy(0,m*11);
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),8);
				cout<<"_______________________________________________________________________________";
			}
	}
	date=1;		mon=counter;	startDOW = dayno() ;	wrap = startDOW;		s=counter-1;
	q=0;		w=0;	     	setpos();
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),2);
	cout << "---------------------";
	GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
	coord = getxy( &csbi);
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15);
	gotoxy(coord.X-17,coord.Y);cout <<months[counter-1]<<" "<<year;
 	q=0;		w=1;			setpos();
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),12);
	cout << "  S  M  T  W  T  F  S" ;		//printing the days
 	q=0;		w=2;			setpos();
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),2);
	cout << "---------------------";
    for (loopCount = 0; loopCount < startDOW; loopCount++)
 	{
 		if(loopCount==0)
			{
				q=3;	w=3;	setpos();
			}
		else
				cout << "   ";				// how many space to indent new month
 	}
	cout<<" ";
 	for (dayCounter=1;dayCounter<=daysInMonth[counter-1]; dayCounter++)
 	{	
	
		if (wrap == 7)						//if Saturday, next line
 			 {
 			 GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
			 coord = getxy( &csbi);
			 u=coord.Y+1;
			 newline();
			 wrap = 0;						//resets day of week counter
 			 weekNumber++;												
 			 }
	 	if(wrap==0) 
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),14);
		else
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15);	 
		date=1;		mon=counter;	 startDOW = dayno() ;					   
		 if (dayCounter<10 && startDOW!=0)	//adds space for single digit days
			 cout <<" "<< dayCounter << " ";	
		 else if (dayCounter<10 && startDOW==0)
		 {	  
			 if (dayCounter==1) 
				{
					GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
					coord = getxy( &csbi);
					u=coord.Y+1;
					newline();
				}
			 cout <<" "<< dayCounter << " ";		//printing the dates
		 }	
		 else
			 cout << dayCounter << " ";				//printing the dates
			 wrap++;
 	}
		 GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
		 coord = getxy( &csbi);
		 gotoxy(coord.X,coord.Y+4);
}

/***************************************************************************************************************************************/

void calendar::monthcal()								//function to print the calendar of a month
{
	COORD coord;
  	date=1;		mon=counter; 	startDOW = dayno() ;	wrap = startDOW;
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),2);
	cout<<"\n\n";
	cout << "---------------------\n";
	GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
	coord = getxy( &csbi);
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15);
	gotoxy(4,coord.Y-1);cout <<months[counter-1]<<" "<<year;
  	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),12);
	cout << "\n  S  M  T  W  T  F  S" << endl;				//printing the days
 	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),2);
	cout << "---------------------" << endl;
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15);
	for (loopCount = 0; loopCount < startDOW; loopCount++)
 	{
 		cout << "   ";						// how many space to indent new month
 	}
		cout<<" ";
 	for (dayCounter=1;dayCounter<=daysInMonth[counter-1]; dayCounter++)
 	{
		 if (wrap == 7)						//if Saturday, next line
 			 {
 			 cout << "\n ";
 			 wrap = 0;						//resets day of week counter
 			 weekNumber++;											
 			 }
		 if(wrap==0) 
		 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),14);
		 else
		 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15);
 		 if (dayCounter<10)					//adds space for single digit days
 			 cout << " ";
 			 cout << dayCounter << " ";		//prints the date
			 wrap++;
 	}
 					cout << "\n\n";
}

/***************************************************************************************************************************************/

void calendar::day2date ()							//Function to print date to the given day in a month
{
	COORD coord;
	if(ket!=0)
	{
	if(isdigit(day[0])==0) 
	{	
		strcpy(str,day);	lim=7;		strcase='d';	chkstr(); daynum=strno;
	}
	else 
		daynum=atoi(day);
	}
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),2);
	gotoxy(28, 6);   	cout<<"_____________________";
	gotoxy(28,17);   	cout<<"_____________________\n";
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15);
	gotoxy(30, 6);		cout<<week[daynum]<<" lies on";
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15);
	gotoxy(28, 6);
	for(j=1;j<=daysInMonth[mon-1];j++)								//loop to check for each day
		{
			date=j;
			wrap=dayno();
			if(daynum==wrap)
			if(j<10)
			  	{
					GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
					coord = getxy( &csbi);
					gotoxy(28,(coord.Y+2));	cout<<bul<<"\t"<<"0"<<j<<" "<<months[mon-1]<<" "<<year;	//printing the dates < 10
				}
			else
         		{
					GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
					coord = getxy( &csbi);
					gotoxy(28,(coord.Y+2));	cout<<bul<<"\t"<<j<<" "<<months[mon-1]<<" "<<year;		//printing dates > 10
				}
		}
}
	
/***************************************************************************************************************************************/

					//MAIN.CPP//

int main (int argc, char *argv[])		//Main function
{
/*******************************************************Password roadblock***************************************************************/    
	SetConsoleTitle("CALENDAR 2.1- By SHIVAM");									
	do{														
		ket=0;met=0;	
		ri=79;		bt=25;
		cal.setscr();											//Resetting the screen size
		cal.roadblock();										//conforms if password or username do not match
		if (a==1)
    		{

				ri=79;		bt=28;
				cal.setscr();
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 12);	//Function to change the colour of output handle in the console		
				cal.gotoxy(28, 8);		cout<<"___________________";
				cal.gotoxy(28,16);		cout<<"___________________";
				cal.gotoxy( 0,21);		cout<<"________________________________________________________________________________\n";
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15);
				cal.gotoxy(34, 8);		cout<<"WELCOME";
				cal.gotoxy(20,18);		cout<<"The PASSWORD or USERNAME is not correct\n\n\n";
   				cal.gotoxy(20,19);		cout<<"\t1. Press 'y/Y' to Enter Again\n";
   				cal.gotoxy(20,20);		cout<<"\t2. Press any other key to EXIT\n";
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 2);
				cal.gotoxy(20,23);		cout<<"Enter : ";
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15);
				cal.gotoxy(29,23);		cin>>pchoice;
				if(pchoice!='y' && pchoice!='Y')
					{
						cal.gotoxy(20,25); cout<<"You chose to exit";
						cal.gotoxy(20,26); cout<<"Good BYE\n";
						cout<<"\nPress any key to end";
      					cal.GetCh();
      					exit(0); 							 //Exiting the program as per users choice
					}
				else 		ket=2;
				if(a!=1) 	met=2; 
			}
	}	while(ket==2 && met!=2);
/***************************************************************************************************************************************/
start:
  	cal.docls();													//Cleares the screen
	ri=79;		bt=27;
	cal.setscr();

/********************************************************CREDITS************************************************************************/
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////			This code (from 2 above lines to 20 lines under this line) must be there with every distribution					   //
///				Removing this part to the code is not allowed in any case,the doing so would directly mean without 					  ///
//				any argument the violation of the free license provided and a case of copyright infringement.						 ////	
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
	cal.gotoxy( 0,14); 	cout<<"CREDITS\n";
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 8);
	cal.gotoxy( 5,15); 	cout<<"           88           88                                             \n";
	cal.gotoxy( 5,16); 	cout<<"           88           88                                             \n";
	cal.gotoxy( 5,17);	cout<<"           88                                                          \n";
	cal.gotoxy( 5,18); 	cout<<",adPPYba,  88,dPPYba,   88  8b       d8  ,adPPYYba,  8 ,dPYba,,adPYba, \n";
	cal.gotoxy( 5,19); 	cout<<"SSS    sa  88P'     8a  88  `8b     d8'  aa     `Y8  88P'    88     8as\n";
	cal.gotoxy( 5,20); 	cout<<"   S8ba    88       88  88   `8b   d8'   ,adPPPPP88  88      88      88\n";
	cal.gotoxy( 5,21); 	cout<<"aa    DSD  88       88  88    `8b,d8'    88,    ,88  88      88      88\n";
	cal.gotoxy( 5,22); 	cout<<"SaYbbdPa'  88       88  88      s8s      `s8bbdPsY8  88      88      88\n";
	cal.gotoxy( 0, 0);
/***************************************************************************************************************************************/
	

	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),12);
	cal.gotoxy( 0, 0);		cout<<"________________________________________________________________________________\n";	//welcome
	cal.gotoxy( 0,11);		cout<<"________________________________________________________________________________\n";
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15);
	cal.gotoxy(28, 0);		cout<<"Welcome to the Calendar";
	cal.gotoxy(70, 0);		cout<<"VER 2.1";
	cout<<"\n\n";
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),7);
	cout<<"OPTIONS";
	cal.gotoxy( 0, 4);
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15);
	cout<<"\t1. Enter 1 to print day of any date\n";					//Options of the program
	cout<<"\t2. Enter 2 to print calendar of any month\n";
	cout<<"\t3. Enter 3 to print calendar of any year\n";
	cout<<"\t4. Enter 4 to find the dates in a month on which a day occurs\n\n\t";
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),10);
    cal.gotoxy(60,26); cout<<"Press 5 to exit";
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),2);
	cal.gotoxy( 8, 9); cout <<"Enter your choice:\t";
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15);
	cin>>numstr; 
	if(isdigit(numstr[0])==0) /* 
								Caution
								Conditional statements to get a interger from the user
								even if he enters garbage which may hang the program		
							 */
		{
			ch=7;/* ch=7 to invoke exception of ch>4*/ 
			cal.repeat() ; 
			if  (ch1=='y'||ch1=='Y') 
				goto start;
		} 
	else ch=atol(numstr); 
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15);
/***************************************************************************************************************************************/
	if (ch==1)															//Prints the day
		{
begi1:
     		do{	
				cal.docls();
         	fla=0;
   			if(again==1)
         	{
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),10);
				cal.gotoxy(30, 4);		cout<<"!!! ENTER AGAIN !!!";
            }
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),2);
			cal.gotoxy(28, 7);   	cout<<"______________________";
			cal.gotoxy(28,20);   	cout<<"______________________\n";
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15);
			cal.gotoxy(34, 7);   	cout<<"DAY-FINDER";
			cal.gotoxy(28, 9);		cout<<"Enter the date(DD)\n";
			cal.gotoxy(28,10);		cin>>numstr; if(isdigit(numstr[0])==0) {again=1; goto begi1;} else date=atol(numstr);
			cal.gotoxy(28,12);		cout<<"Enter the month\n";
			cal.gotoxy(28,13);		cin>>numstr; if(isdigit(numstr[0])==0) {strcpy(str,numstr); lim=12;	strcase='m';	cal.chkstr(); mon=strno;} else mon=atol(numstr);
			cal.gotoxy(28,15);		cout<<"Enter the year(YYYY)\n";
			cal.gotoxy(28,16);		cin>>numstr; if(isdigit(numstr[0])==0) {again=1; goto begi1;} else year=atol(numstr);
			cal.chkdate();
			}while(again==1);
			x=cal.dayno();
			if(flag==0)
				{
					cal.gotoxy(28,18);		cout<<"The day was : ";
				}
			else if(flag==1)
				{
					cal.gotoxy(28,18);		cout<<"The day will be : ";
				}
			else if(flag==2)
				{
					cal.gotoxy(28,18);		cout<<"Today is a : ";
				}
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),12);
			cout<<week[x]<<"\n";
		}
/***************************************************************************************************************************************/
	if (ch==2)															//prints the calendar of the month
		{
begi2:		do{
			cal.docls();
   			if(again==1)
         	{
				SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),10);
         		cal.gotoxy(28, 4);	cout<<"!!! ENTER AGAIN !!!";
            }
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),2);
			cal.gotoxy(28, 7);   	cout<<"____________________";
			cal.gotoxy(28,15);   	cout<<"____________________\n";
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15);
			cal.gotoxy(31, 7);   	cout<<"MONTH-CALENDAR";
			cal.gotoxy(28, 9); 		cout<<"Enter the month\n";
			cal.gotoxy(28,10); 		cin>>numstr; if(isdigit(numstr[0])==0) {strcpy(str,numstr); lim=12;	strcase='m';	cal.chkstr(); mon=strno;} else {mon=atol(numstr);fla = 0;}
			cal.gotoxy(28,12);		cout<<"Enter the year{YYYY}\n";
			cal.gotoxy(28,13);		cin>>numstr; if(isdigit(numstr[0])==0) {again=1; goto begi2;} else year=atol(numstr);
			date=1;
         	counter = mon;
		 	cal.chkdate();
			}while(again==1);
			cal.docls();
			cal.monthcal();
		}
/***************************************************************************************************************************************/
	if (ch==3)															//prints the calendar of the year
		{
begi3:		
			do{
			cal.docls();
   			if(again == 1)
  				{
					SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),10);
         			cal.gotoxy(29, 4);	cout<<"!!! ENTER AGAIN !!!";
				}
			again=0;
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),2);
			cal.gotoxy(28, 7);   	cout<<"_____________________";
			cal.gotoxy(28,13);   	cout<<"_____________________\n";
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15);
			cal.gotoxy(31, 7);   	cout<<"YEARLY-CALENDAR";
			cal.gotoxy(28, 9);		cout<<"Enter the year(YYYY)\n";
			cal.gotoxy(28,11);		cin>>numstr; if(isdigit(numstr[0])==0) {again=1; goto begi3;} else year=atol(numstr);
			date=1;
			mon=1;
			cal.chkdate();
			}while(again==1);
      		cal.docls();

			for (counter = 1; counter <= 12; counter++)
 				{
					cal.printAll();
 				}
		}
/***************************************************************************************************************************************/
	if (ch==4)															//prints the dates on which a day lies in a month
		{
begi4:
			do{
			cal.docls();
   			if(again == 1)
         		{
					SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),10);
         			cal.gotoxy(29, 4);	cout<<"!!! ENTER AGAIN !!!";
				}
			again=0;
			fla=0;
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),2);
			cal.gotoxy(28, 7);   	cout<<"________________________";
			cal.gotoxy(28,18);   	cout<<"________________________\n";
			SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15);
			cal.gotoxy(35, 7);   	cout<<"DATE-FINDER";
			cal.gotoxy(28, 9);		cout<<"Enter the day\n";
			cal.gotoxy(28,10);		cin>>numstr; if(isdigit(numstr[0])==0) {strcpy(str,numstr);lim=7;	strcase='d';	cal.chkstr(); daynum=strno;}else{if (atol(numstr)<8){daynum=atoi(numstr);ket=0;}else{again=1;goto begi4;}}			
			cal.gotoxy(28,12); 		cout<<"Enter the month\n";
			cal.gotoxy(28,13);		cin>>numstr; if(isdigit(numstr[0])==0) {strcpy(str,numstr); lim=12;	strcase='m';	cal.chkstr(); mon=strno;}else mon=atol(numstr);
			cal.gotoxy(28,15);		cout<<"Enter the year\n";
			cal.gotoxy(28,16);		cin>>numstr; if(isdigit(numstr[0])==0) {again=1; goto begi4;} else year=atol(numstr);
			cout<<"\n";			cout<<"\n";
			date=1;
			cal.chkdate();
			}while(again==1);
			cal.docls();
			if(daynum==7)		daynum=0;
			cal.day2date ();
			goto rep;
		}
/***************************************************************************************************************************************/
	if (ch==5)                                                //BYE   (function to exit)
   		{
      		cal.gotoxy(25,26);	exit(0);
		}
/***************************************************************************************************************************************/
	else
rep:
		cal.repeat() ;
	if  (ch1=='y'||ch1=='Y')
		goto start;

return 0;						//end of main statement
}

//end of code
//made by shivam mathur
